import http from '../../utils/http';
import * as types from '../mutations-type'

const state = {};

const actions = {

    //添加地址
    [types.ADDRESS_ADD]({}, info) {
        return new Promise((resolve) => {
            http.post('/user/addr.add', info).then((res) => {
                return resolve(res.data);
            });
        });
    },
    //获取地址列表
    [types.GET_ADDRESS_LIST]({}) {
        return new Promise((resolve) => {
            http.post('/user/addr.lists').then((res) => {
                return resolve(res.data);
            });
        });
    },
    //编辑地址
    [types.ADDRESS_EDIT]({}, info) {
        return new Promise((resolve) => {
            http.post('/user/addr.edit', info).then((res) => {
                return resolve(res.data);
            });
        });
    },
    //删除地址
    [types.ADDRESS_DEL]({}, id) {
        return new Promise((resolve) => {
            http.post('/user/addr.del', id).then((res) => {
                return resolve(res.data);
            });
        });
    },
    //设置默认地址
    [types.ADDRESS_DEFAULT]({}, id) {
        return new Promise((resolve) => {
            http.post('/user/addr.setDefault', id).then((res) => {
                return resolve(res.data);
            });
        });
    },

};


const mutations = {};


export default {
    state,
    actions,
    mutations,
    getters: {}
}
